package chp11;

import java.util.Scanner;

public class Game3 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Computer computer = new Computer();
        Person person = new Person();
        computer.init();
        person.init();

        while (true) {
            int myFist = person.showFist();
            int compFist = computer.showFist();

            //比较胜负
            if (myFist == compFist) {
                System.out.println("结果：平手");
            } else if (myFist == 1 && compFist == 3 || myFist == 2 && compFist == 1 || myFist == 3 && compFist == 2) {
                System.out.println("结果：你赢了");
                person.score++;
            } else {
                System.out.println("结果：你输了");
                computer.score++;
            }

            System.out.print("\n是否开始下一轮(y/n):");
            String answer = input.next();
            if(answer.equals("n")){
                break;
            }
        }
        System.out.println(person.name+" VS "+computer.name);
        System.out.println(person.score +"  : " + computer.score);
    }
}
